#!/usr/bin/env python
# This is mock RMS script; not very functional ...
import json
import sys
import os

config = {"exit_status" : 0}
if os.path.isfile("action.json"):
    config = json.load(open("action.json"))

if "target_file" in config:
    with open(config["target_file"], "w") as f:
        f.write("this is the target file\n")

with open('env.json', 'w') as f:
    env = {}
    for key in ("PATH", "RMS_TEST_VAR", "PYTHONPATH"):
        if key in os.environ:
            env[key] = os.environ[key]

    json.dump(env, f)

sys.exit(config["exit_status"])
